<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Class: ActiveScaffold::DataStructures::Set</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Class</strong></td>
          <td class="class-name-in-header">ActiveScaffold::DataStructures::Set</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../../../files/vendor/plugins/active_scaffold/lib/data_structures/set_rb.html">
                vendor/plugins/active_scaffold/lib/data_structures/set.rb
                </a>
        <br />
            </td>
        </tr>

        <tr class="top-aligned-row">
            <td><strong>Parent:</strong></td>
            <td>
                <a href="../../Object.html">
                Object
               </a>
            </td>
        </tr>
        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">



   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M000401">&lt;&lt;</a>&nbsp;&nbsp;
      <a href="#M000406">[]</a>&nbsp;&nbsp;
      <a href="#M000400">add</a>&nbsp;&nbsp;
      <a href="#M000407">each</a>&nbsp;&nbsp;
      <a href="#M000409">empty?</a>&nbsp;&nbsp;
      <a href="#M000402">exclude</a>&nbsp;&nbsp;
      <a href="#M000405">find_by_name</a>&nbsp;&nbsp;
      <a href="#M000404">find_by_names</a>&nbsp;&nbsp;
      <a href="#M000398">label</a>&nbsp;&nbsp;
      <a href="#M000408">length</a>&nbsp;&nbsp;
      <a href="#M000399">new</a>&nbsp;&nbsp;
      <a href="#M000403">remove</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->
    <div id="includes">
      <h3 class="section-bar">Included Modules</h3>

      <div id="includes-list">
        <span class="include-name">Enumerable</span>
        <span class="include-name"><a href="../Configurable.html">ActiveScaffold::Configurable</a></span>
      </div>
    </div>

    <div id="section">





    <div id="attribute-list">
      <h3 class="section-bar">Attributes</h3>

      <div class="name-list">
        <table>
        <tr class="top-aligned-row context-row">
          <td class="context-item-name">label</td>
          <td class="context-item-value">&nbsp;[W]&nbsp;</td>
          <td class="context-item-desc"></td>
        </tr>
        </table>
      </div>
    </div>
      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Class methods</h3>

      <div id="method-M000399" class="method-detail">
        <a name="M000399"></a>

        <div class="method-heading">
          <a href="#M000399" class="method-signature">
          <span class="method-name">new</span><span class="method-args">(*args)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000399-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000399-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/active_scaffold/lib/data_structures/set.rb, line 11</span>
11:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
12:       <span class="ruby-ivar">@set</span> = []
13:       <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">add</span> <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>
14:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <h3 class="section-bar">Public Instance methods</h3>

      <div id="method-M000401" class="method-detail">
        <a name="M000401"></a>

        <div class="method-heading">
          <span class="method-name">&lt;&lt;</span><span class="method-args">(*args)</span>
        </div>
      
        <div class="method-description">
          <p>
Alias for <a href="Set.html#M000400">add</a>
</p>
        </div>
      </div>

      <div id="method-M000406" class="method-detail">
        <a name="M000406"></a>

        <div class="method-heading">
          <span class="method-name">[]</span><span class="method-args">(name)</span>
        </div>
      
        <div class="method-description">
          <p>
Alias for <a href="Set.html#M000405">find_by_name</a>
</p>
        </div>
      </div>

      <div id="method-M000400" class="method-detail">
        <a name="M000400"></a>

        <div class="method-heading">
          <a href="#M000400" class="method-signature">
          <span class="method-name">add</span><span class="method-args">(*args)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
the way to <a href="Set.html#M000400">add</a> items to the set.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000400-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000400-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/active_scaffold/lib/data_structures/set.rb, line 17</span>
17:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">add</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
18:       <span class="ruby-identifier">args</span>.<span class="ruby-identifier">flatten!</span> <span class="ruby-comment cmt"># allow [] as a param</span>
19:       <span class="ruby-identifier">args</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">arg</span><span class="ruby-operator">|</span>
20:         <span class="ruby-identifier">arg</span> = <span class="ruby-identifier">arg</span>.<span class="ruby-identifier">to_sym</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">arg</span>.<span class="ruby-identifier">is_a?</span> <span class="ruby-constant">String</span>
21:         <span class="ruby-ivar">@set</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">arg</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@set</span>.<span class="ruby-identifier">include?</span> <span class="ruby-identifier">arg</span> <span class="ruby-comment cmt"># avoid duplicates</span>
22:       }
23:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000407" class="method-detail">
        <a name="M000407"></a>

        <div class="method-heading">
          <a href="#M000407" class="method-signature">
          <span class="method-name">each</span><span class="method-args">() {|i| ...}</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000407-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000407-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/active_scaffold/lib/data_structures/set.rb, line 47</span>
47:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">each</span>
48:       <span class="ruby-ivar">@set</span>.<span class="ruby-identifier">each</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">i</span><span class="ruby-operator">|</span> <span class="ruby-keyword kw">yield</span> <span class="ruby-identifier">i</span> }
49:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000409" class="method-detail">
        <a name="M000409"></a>

        <div class="method-heading">
          <a href="#M000409" class="method-signature">
          <span class="method-name">empty?</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000409-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000409-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/active_scaffold/lib/data_structures/set.rb, line 56</span>
56:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">empty?</span>
57:       <span class="ruby-ivar">@set</span>.<span class="ruby-identifier">empty?</span>
58:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000402" class="method-detail">
        <a name="M000402"></a>

        <div class="method-heading">
          <a href="#M000402" class="method-signature">
          <span class="method-name">exclude</span><span class="method-args">(*args)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
the way to <a href="Set.html#M000403">remove</a> items from the set.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000402-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000402-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/active_scaffold/lib/data_structures/set.rb, line 27</span>
27:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">exclude</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
28:       <span class="ruby-identifier">args</span>.<span class="ruby-identifier">flatten!</span> <span class="ruby-comment cmt"># allow [] as a param</span>
29:       <span class="ruby-identifier">args</span>.<span class="ruby-identifier">collect!</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">a</span><span class="ruby-operator">|</span> <span class="ruby-identifier">a</span>.<span class="ruby-identifier">to_sym</span> } <span class="ruby-comment cmt"># symbolize the args</span>
30:       <span class="ruby-ivar">@set</span>.<span class="ruby-identifier">reject!</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">c</span><span class="ruby-operator">|</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">include?</span> <span class="ruby-identifier">c</span>.<span class="ruby-identifier">to_sym</span> } <span class="ruby-comment cmt"># reject all items specified</span>
31:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000405" class="method-detail">
        <a name="M000405"></a>

        <div class="method-heading">
          <a href="#M000405" class="method-signature">
          <span class="method-name">find_by_name</span><span class="method-args">(name)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
returns the item of the given name.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000405-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000405-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/active_scaffold/lib/data_structures/set.rb, line 40</span>
40:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">find_by_name</span>(<span class="ruby-identifier">name</span>)
41:       <span class="ruby-comment cmt"># this works because of `def item.=='</span>
42:       <span class="ruby-identifier">item</span> = <span class="ruby-ivar">@set</span>.<span class="ruby-identifier">find</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">c</span><span class="ruby-operator">|</span> <span class="ruby-identifier">c</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">name</span> }
43:       <span class="ruby-identifier">item</span>
44:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000404" class="method-detail">
        <a name="M000404"></a>

        <div class="method-heading">
          <a href="#M000404" class="method-signature">
          <span class="method-name">find_by_names</span><span class="method-args">(*names)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
returns an array of items with the provided names
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000404-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000404-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/active_scaffold/lib/data_structures/set.rb, line 35</span>
35:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">find_by_names</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">names</span>)
36:       <span class="ruby-ivar">@set</span>.<span class="ruby-identifier">find_all</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">item</span><span class="ruby-operator">|</span> <span class="ruby-identifier">names</span>.<span class="ruby-identifier">include?</span> <span class="ruby-identifier">item</span> }
37:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000398" class="method-detail">
        <a name="M000398"></a>

        <div class="method-heading">
          <a href="#M000398" class="method-signature">
          <span class="method-name">label</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000398-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000398-source">
<pre>
   <span class="ruby-comment cmt"># File vendor/plugins/active_scaffold/lib/data_structures/set.rb, line 7</span>
7:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">label</span>
8:       <span class="ruby-identifier">as_</span>(<span class="ruby-ivar">@label</span>)
9:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000408" class="method-detail">
        <a name="M000408"></a>

        <div class="method-heading">
          <a href="#M000408" class="method-signature">
          <span class="method-name">length</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
returns the number of items in the set
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000408-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000408-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/active_scaffold/lib/data_structures/set.rb, line 52</span>
52:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">length</span>
53:       <span class="ruby-ivar">@set</span>.<span class="ruby-identifier">length</span>
54:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000403" class="method-detail">
        <a name="M000403"></a>

        <div class="method-heading">
          <span class="method-name">remove</span><span class="method-args">(*args)</span>
        </div>
      
        <div class="method-description">
          <p>
Alias for <a href="Set.html#M000402">exclude</a>
</p>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>